package com.jiangyg.mall.coupon.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.coupon.dao.HomeSubjectSpuDao;
import com.jiangyg.mall.coupon.dto.HomeSubjectSpuDTO;
import com.jiangyg.mall.coupon.entity.HomeSubjectSpu;
import com.jiangyg.mall.coupon.vo.HomeSubjectSpuVO;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class HomeSubjectSpuServiceImpl extends BaseServiceImpl<HomeSubjectSpuDao, HomeSubjectSpu> implements HomeSubjectSpuService {

    @Autowired
    public HomeSubjectSpuServiceImpl(HomeSubjectSpuDao homeSubjectSpuDao) {
        super(homeSubjectSpuDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<HomeSubjectSpuVO> selectPagination(Pagination<HomeSubjectSpuVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, HomeSubjectSpuVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(HomeSubjectSpuDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public HomeSubjectSpuVO selectById(Long homeSubjectSpuId) throws Exception {
        return this.executeSelectById(homeSubjectSpuId, HomeSubjectSpuVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> homeSubjectSpuIds) {
        return this.baseMapper.deleteBatchIds(homeSubjectSpuIds) > 0;
    }

}
